package xj.toolkit.jmx.model;

import java.io.Serializable;
import java.util.Arrays;

public class FeaturesDescription implements Cloneable, Serializable {
	private static final long serialVersionUID = -7911776990509558339L;
	private String _name;
	private Unit[] _units;

	public static class Unit implements Cloneable, Serializable {
		private static final long serialVersionUID = 6914552145548357915L;
		private String _objectName;
		private String[] _featureNames;

		public Unit clone() throws CloneNotSupportedException {
			return (Unit) super.clone();
		}

		public Unit(String objectName, String[] attributeNames) {
			this._objectName = objectName;
			this._featureNames = attributeNames;
		}

		public Unit() {
		}

		public String getObjectName() {
			return this._objectName;
		}

		public void setObjectName(String objectName) {
			this._objectName = objectName;
		}

		public String[] getFeatureNames() {
			return this._featureNames;
		}

		public void setFeatureNames(String[] names) {
			this._featureNames = names;
		}

		public int hashCode() {
			int prime = 31;
			int result = 1;
			result = 31 * result + Arrays.hashCode(this._featureNames);
			result = 31
					* result
					+ (this._objectName == null ? 0 : this._objectName
							.hashCode());

			return result;
		}

		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			Unit other = (Unit) obj;
			if (!Arrays.equals(this._featureNames, other._featureNames)) {
				return false;
			}
			if (this._objectName == null) {
				if (other._objectName != null) {
					return false;
				}
			} else if (!this._objectName.equals(other._objectName)) {
				return false;
			}
			return true;
		}

		public String toString() {
			return "[on=" + this._objectName + ", features="
					+ Arrays.toString(this._featureNames) + "]";
		}
	}

	protected FeaturesDescription clone() throws CloneNotSupportedException {
		return (FeaturesDescription) super.clone();
	}

	public FeaturesDescription(String name, Unit... units) {
		this._name = name;
		this._units = units;
	}

	public FeaturesDescription() {
	}

	public String getName() {
		return this._name;
	}

	public void setName(String name) {
		this._name = name;
	}

	public Unit[] getUnits() {
		return this._units;
	}

	public void setUnits(Unit[] units) {
		this._units = units;
	}

	public int hashCode() {
		int prime = 31;
		int result = 1;
		result = 31 * result + Arrays.hashCode(this._units);
		result = 31 * result + (this._name == null ? 0 : this._name.hashCode());

		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		FeaturesDescription other = (FeaturesDescription) obj;
		if (!Arrays.equals(this._units, other._units)) {
			return false;
		}
		if (this._name == null) {
			if (other._name != null) {
				return false;
			}
		} else if (!this._name.equals(other._name)) {
			return false;
		}
		return true;
	}

	public String toString() {
		return "features [name=" + this._name + ", units="
				+ Arrays.toString(this._units) + "]";
	}
}
